sonic/validator: replace sonic-yang-mgmt+libyang with generated Pydan… - #2253
Merged
Conversation
There was a problem hiding this comment.
Sorry @berendt, your pull request is larger than the review limit of 150000 diff characters
berendt
force-pushed
the
change-sonic-validate
branch
from
May 4, 2026 20:02
71e5dd2 to
a50fbe9
Compare
…tic schemas The previous validator imported sonic_yang (a SWIG binding to libyang1) which is not packaged for Alpine and is not available on the runtime image. Replace it with a build-time YANG→Pydantic transpiler whose committed output is the runtime schema source — runtime needs only pydantic, no native dependencies. - tools/sonic_yang_to_pydantic.py walks pyang's AST over files/sonic/yang_models/ and emits one Pydantic v2 model per ConfigDB table. - osism/tasks/conductor/sonic/_generated/_schemas.py is the committed output (205 tables); regenerated via the tool when YANG models are refreshed. - Validator API stays stable for callers; ValidatorUnavailable / load_yang_context are dropped along with the --yang-dir flag and SONIC_YANG_MODELS_DIR setting. - Tables not yet covered by upstream YANG are reported as warnings, not errors. - Containerfile drops libyang apk and the yang_models COPY; requirements.sonic.txt switches from the sonic-yang-mgmt VCS pin to pydantic; pyang moves out of runtime requirements (only needed when regenerating). Cross-table leafref enforcement is intentionally out of scope here and tracked in #2252. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
berendt
force-pushed
the
change-sonic-validate
branch
from
May 4, 2026 20:04
a50fbe9 to
e235a7d
Compare
5 tasks
osfrickler
pushed a commit
that referenced
this pull request
Jun 2, 2026
The sonic-yang-mgmt git dependency was added in #2191 for the original libyang-based SONiC config validator. #2253 replaced that validator with offline-generated Pydantic schemas and cleaned up requirements.txt, requirements.sonic.txt and the Containerfile, but left the dependency behind in Pipfile/Pipfile.lock. Nothing imports sonic_yang_mgmt anymore (the runtime validator depends only on pydantic, and the schema generator uses pyang), so remove it from both files and refresh the Pipfile hash. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tic schemas
The previous validator imported sonic_yang (a SWIG binding to libyang1) which is not packaged for Alpine and is not available on the runtime image. Replace it with a build-time YANG→Pydantic transpiler whose committed output is the runtime schema source — runtime needs only pydantic, no native dependencies.
Cross-table leafref enforcement is intentionally out of scope here and tracked in #2252.
AI-assisted: Claude Code